public class State implements Comparable<State>{

	public String initName;
	public String name;
	public int output;
	
	public State(String name){
		this.name = name;
	}

	public State(String name, int output) {
		this.name = name;
		this.output = output;
	}
	
	public State(String name, String initName, int output){
		this(name, output);
		this.initName = initName;
	}		

	/**
	 * two states are equal if they have the same name and same 
	 * initial state name
	 */
	@Override
	public boolean equals(Object o) {
		return toString().equalsIgnoreCase(o.toString());
	}

	/**
	 * compares the state names
	 * if equal and the initial state names are set, compares those
	 */
	@Override
	public int compareTo(State arg0) {
		if(initName == null || name.compareToIgnoreCase(arg0.name) != 0)
			return name.compareToIgnoreCase(arg0.name);
		else
			return initName.compareToIgnoreCase(arg0.initName);		
	}
	
	public String toString(){
		if(initName == null)
			return name;
		else
			return "("+initName+","+name+")";
	}
	
	/**
	 * returns the hashCode() of the state name
	 */
	@Override
	public int hashCode(){
		return name.hashCode();
	}
}
